using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.SharePoint;

namespace LenninSoftware.FormEditor
{
    public class EditDocumentControl: Control
    {

        private string _fileRelativeUrl;

        public string FileRelativeUrl
        {
            get { return _fileRelativeUrl; }
            set { _fileRelativeUrl = value; }
        }

        private string _documentTitle;

        public string DocumentTitle
        {
            get { return _documentTitle; }
            set { _documentTitle = value; }
        }

        protected override void Render(HtmlTextWriter writer)
        {
            writer.WriteLine("<a href=\"{0}\" onclick=\"editDocumentWithProgID2('{1}', '', 'SharePoint.OpenDocuments', '0', '{2}', '0')\"> {3} </a>",
               //SPContext.Current.Site.HostName + FileRelativeUrl, 
               "#",
               FileRelativeUrl, 
               SPContext.Current.Site.HostName + SPContext.Current.Web.ServerRelativeUrl,
               DocumentTitle);

            writer.WriteLine("<br><span> Click to edit the document</span>");

        }
    }
}
